(*
#load "mlpfi.cma";;
#install_printer Mlpfi.print;;
*)

open Common;;

module M = Mlpfi;;

let zero = M.of_string "0.0";;

let rec harmonic n store =
  if n = 0 then store 
  else harmonic (n-1) (M.add store (M.inv (M.of_string (string_of_int n))));;

let harmonic n =
  let store = ref zero in
    (for i = 1 to n do
      store := M.add !store (M.inv (M.of_string (string_of_int i)));
     done;
     !store)

let atan n = funpow n M.atan (M.of_string "1.0")

let n = 1000000;;

(* print_stringl ("Ocaml Harmonic: " ^ string_of_int n ^ " = ");; *)
(* M.print (harmonic n);; *)
print_stringl ("Ocaml Atan: " ^ string_of_int n ^ " = ");;
M.print (atan n);;
